/*    */ package com.zimbra.cs.account.callback;
/*    */ 
/*    */ import com.zimbra.common.account.Key.AccountBy;
/*    */ import com.zimbra.common.account.Key.DomainBy;
/*    */ import com.zimbra.common.service.ServiceException;
/*    */ import com.zimbra.common.util.EmailUtil;
/*    */ import com.zimbra.cs.account.Account;
/*    */ import com.zimbra.cs.account.AttributeCallback;
/*    */ import com.zimbra.cs.account.AttributeCallback.MultiValueMod;
/*    */ import com.zimbra.cs.account.Domain;
/*    */ import com.zimbra.cs.account.Entry;
/*    */ import com.zimbra.cs.account.Provisioning;
/*    */ import java.util.Map;
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ public class AllowFromAddress
/*    */   extends AttributeCallback
/*    */ {
/*    */   public void preModify(CallbackContext context, String attrName, Object value, Map attrsToModify, Entry entry)
/*    */     throws ServiceException
/*    */   {
/* 42 */     AttributeCallback.MultiValueMod mod = multiValueMod(attrsToModify, "zimbraAllowFromAddress");
/* 43 */     if ((mod != null) && ((mod.adding()) || (mod.replacing()))) {
/* 44 */       for (String addr : mod.valuesSet()) {
/* 45 */         checkAddress(addr);
/*    */       }
/*    */     }
/*    */   }
/*    */   
/*    */   private void checkAddress(String addr) throws ServiceException {
/* 51 */     Provisioning prov = Provisioning.getInstance();
/* 52 */     String domain = EmailUtil.getValidDomainPart(addr);
/* 53 */     if (domain != null) {
/* 54 */       Domain internalDomain = prov.getDomain(Key.DomainBy.name, domain, true);
/* 55 */       if (internalDomain != null) {
/* 56 */         if (prov.isDistributionList(addr)) {
/* 57 */           throw ServiceException.INVALID_REQUEST("zimbraAllowFromAddress may not contain a distribution list: " + addr, null);
/*    */         }
/*    */         
/* 60 */         Account acct = prov.get(Key.AccountBy.name, addr);
/* 61 */         if (acct != null) {
/* 62 */           throw ServiceException.INVALID_REQUEST("zimbraAllowFromAddress may not contain an internal account: " + addr, null);
/*    */         }
/*    */       }
/*    */     }
/*    */   }
/*    */   
/*    */   public void postModify(CallbackContext context, String attrName, Entry entry) {}
/*    */ }


/* Location:              /home/mint/zimbrastore.jar!/com/zimbra/cs/account/callback/AllowFromAddress.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       0.7.1
 */